<template>
	<view>
		<popup v-if="!isShow" ref="mapState" protocolPath='/pages/common/common?weburl=https://yunzhuan.zgwlkj.cn/'
			:policyPath="policyPath"
			@popupState="popupState"></popup>
		<uni-popup ref="hint" type="center" :maskClick="false">
			<view class="column align-items-center" style="width: 600rpx;padding: 20rpx 20rpx;background-color: #FFFFFF;border-radius: 20rpx;">
				<view class="text-view" style="font-size: 36rpx;">
					温馨提示
				</view>
				<view class="text-view" style="font-size: 28rpx;color: #868686;">
					请同意并接受用户隐私政策后,再开始使用云赚的服务
				</view>
				<view class="button2" @click="close()" style="">
					重新阅读
				</view>
				<view class="button1" hover-class="button-press" @click="quit" style="">
					退出
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import popup from '@/components/DuDu-popup/DuDu-popup.vue'
	export default {
		components: {
			popup
		},
		data() {
			return {
				isShow: false,
				policyPath:"/pages/common/common?weburl=https://www.zgwlkj.cn/yunzhuan/%E9%9A%90%E7%A7%81%E6%94%BF%E7%AD%96.html"
			};
		},
		onShow() {
			// uni.setStorageSync(this.$util.HAS_USER_INFO,false)
			this.isShow = plus.runtime.isAgreePrivacy()
			if(uni.getSystemInfoSync().platform === 'ios'){
				this.policyPath = "/pages/common/common?weburl=https://yunzhuan.zgwlkj.cn/apple"
			}
			if (!uni.getStorageSync(this.$util.HAS_USER_INFO) && plus.runtime.isAgreePrivacy()) {
				uni.reLaunch({
					url: "/pages/login/login"
				})
			} else if (uni.getStorageSync(this.$util.HAS_USER_INFO) && plus.runtime.isAgreePrivacy()) {
				uni.switchTab({
					url: "/pages/index/index"
				})
			}
		},
		methods: {
			popupState(e) { //e->false取消 true确认
				let that = this
				if (e) {
					//动态授权获取设备信息权限
					plus.device.getInfo({
						success:function(e){
							console.log('getDeviceInfo success: '+JSON.stringify(e));
							plus.runtime.agreePrivacy();
							uni.reLaunch({
								url: "/pages/login/login"
							})
						},
						fail:function(e){
							plus.runtime.disagreePrivacy();
							uni.reLaunch({
								url: "/pages/login/login"
							})
						}
					});
				} else {
					plus.runtime.disagreePrivacy();
					this.isShow=true
					this.$refs.hint.open()
					this.$forceUpdate()
				}
			},
			close(){
				this.$refs.hint.close()
				this.isShow=false
			},
			quit(){
				this.$refs.hint.close()
				uni.reLaunch({
					url: "/pages/login/login"
				})
			}
		}
	}
</script>

<style lang="scss">
	
	.button1 {
		width: 560rpx;
		text-align: center;
		height: 80rpx;
		line-height: 80rpx;
		font-size: 32rpx;
		color: #828282;
		background-color: #FFFFFF;
		margin-top: 20rpx;
		border-radius: 15rpx;
	}
	
	.button2 {
		width: 560rpx;
		text-align: center;
		height: 80rpx;
		line-height: 80rpx;
		color: #FFFFFF;
		background-color: #08ACEE;
		border-radius: 15rpx;
	}
	
	.button-press{
		background-color: #d6d6d6;
	}

	.text-view {
		text-align: center;
		padding: 20rpx 20rpx;
	}
</style>
